Ad-blocking via /etc/hosts ([primer][ah])

After installation the script runs immediately, and then every week.

Your existing hosts file will be copied to hosts.head during installation. It
is then used as the head of the new, ad-blocking hosts file.
You can edit this file between updates. If you uninstall hosts-block, it will
become your regular hosts file again.

By default only one or two lists are used, but you can add as
many sources as you want - they'll be combined to create the ultimate ad-blocking hosts file.

3 formats are supported:

- uBlock-like syntax (it will be stripped of extra information HOSTS cannot deal with)
- lists of URLs to actual lists
- actual lists of hosts (the script is flexible here - with or without leading '0.0.0.0', remove standard entries e.g. '::1 localhost6', remove comments etc.)

If you want stricter or less strict blocking, copy
`/usr/share/doc/hosts-block/cfg.sh` to `/home/defaultuser/.config/hosts-block/`
and edit it to your liking.

You can whitelist sites by creating
`/home/defaultuser/.config/hosts-block/whitelist.txt` - the format is much like hosts
itself
but without the numerical address, so just the \[sub.]domain.tld, one per line (AFAIK no wildcards are supported).
Same for blacklist.txt/blacklisting.

Please keep in mind that the www. subdomain has to be specified explicitely, if so desired.
In other words, for most domains you'll probably want 2 lines:

    domain.tld
    www.domain.tld

The script is run once a week (currently hardcoded) through a systemd
timer/service.

If one of the config files is edited, a new run is triggered.

You can regenerate the hosts manually file with `devel-su systemctl start
hosts-block.service`

The script sends various graphical notifications when something important
happens (good or bad).

# Before installing the package

There is nothing to do if you haven't customized /etc/hosts. But if you want to preserve its content please move/copy it to /etc/hosts.head
before installing this package.
If /etc/hosts.head does not exist yet it will be created with sane default values, and from then on it
will be used as the top of /etc/hosts unaltered.

It is, however, not a good idea to put to-be-blocked domains in /etc/hosts.head. Please use the blacklist feature for that (if you think
these domains haven't been covered by one of the available blocklists already).

If you uninstall hosts-block /etc/hosts.head will become your regular hosts file again.

Source  
[Framagit.org](https://framagit.org/ohnonot/sfos/)  
[Notabug.org](https://notabug.org/ohnonot/sfos/)

[ah]: https://nordvpn.com/blog/use-hosts-file-block-ads-malware/
